package com.wx.pay.common;

import java.io.Serializable;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/7/13 22:30
 */
@SuppressWarnings("all")
public class ResultData<T> implements Serializable
{
    private static final long serialVersionUID = 3019198583261139921L;

    public static final int SUCCESS = 1;

    public static final int FAIL = 0;

    private int status;

    private long count;

    private String errCode;

    private String errMsg;

    private T data;

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }

    public long getCount()
    {
        return count;
    }

    public void setCount(long count)
    {
        this.count = count;
    }

    public String getErrCode()
    {
        return errCode;
    }

    public void setErrCode(String errCode)
    {
        this.errCode = errCode;
    }

    public String getErrMsg()
    {
        return errMsg;
    }

    public void setErrMsg(String errMsg)
    {
        this.errMsg = errMsg;
    }

    public T getData()
    {
        return data;
    }

    public void setData(T data)
    {
        this.data = data;
    }

    @Override
    public String toString()
    {
        return "ResultData{" +
                "status=" + status +
                ", count=" + count +
                ", errCode='" + errCode + '\'' +
                ", errMsg='" + errMsg + '\'' +
                ", data=" + data +
                '}';
    }

    public ResultData()
    {
    }

    /**
     * 只有状态
     *
     * @param status
     */
    public ResultData(int status)
    {
        this.status = status;
    }

    /**
     * 有状态有数据
     *
     * @param status
     * @param data
     */
    public ResultData(int status, T data)
    {
        this.status = status;
        this.data = data;
    }

    /**
     * 有状态,有错误码,有错误信息
     *
     * @param status
     * @param errCode
     * @param errMsg
     */
    public ResultData(int status, String errCode, String errMsg)
    {
        this.status = status;
        this.errCode = errCode;
        this.errMsg = errMsg;
    }


    /**
     * 成功
     *
     * @return
     */
    public static ResultData success()
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.SUCCESS);
        return resultData;
    }

    /**
     * 成功
     *
     * @return
     */
    public static ResultData success(Object data)
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.SUCCESS);
        resultData.setData(data);
        return resultData;
    }

    public static ResultData success(long count, Object data)
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.SUCCESS);
        resultData.setCount(count);
        resultData.setData(data);
        return resultData;
    }

    /**
     * 成功
     *
     * @return
     */
    public static ResultData success(String errMsg, Object data)
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.SUCCESS);
        resultData.setErrMsg(errMsg);
        resultData.setData(data);
        return resultData;
    }

    /**
     * 成功
     *
     * @param errCode
     * @param errMsg
     * @param data
     * @return
     */
    public static ResultData success(String errCode, String errMsg, Object data)
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.SUCCESS);
        resultData.setErrCode(errCode);
        resultData.setErrMsg(errMsg);
        resultData.setData(data);
        return resultData;

    }

    /**
     * 成功
     *
     * @param errCode
     * @param errMsg
     * @return
     */
    public static ResultData fail(String errCode, String errMsg)
    {
        ResultData resultData = new ResultData();
        resultData.setStatus(ResultData.FAIL);
        resultData.setErrCode(errCode);
        resultData.setErrMsg(errMsg);
        return resultData;
    }
}
